package zx.x.modules.yshapp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import zx.x.common.utils.PageUtils;
import zx.x.common.utils.Query;
import zx.x.modules.yshapp.dao.RaffleAppDao;
import zx.x.modules.yshapp.entity.RaffleEntity;
import zx.x.modules.yshapp.service.RaffleService;

import java.util.Map;


@Service("raffleAppService")
public class RaffleAppServiceImpl extends ServiceImpl<RaffleAppDao, RaffleEntity> implements RaffleService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<RaffleEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("community_id", params.get("communityId"));
        queryWrapper.eq("is_open", 1);
        queryWrapper.orderBy(true,false,"open_time");

        IPage<RaffleEntity> page = this.page(
                new Query<RaffleEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }
}